package mango.orm;

import mango.orm.connect.Connector;
import mango.orm.entity.Entity;
import mango.orm.impl.DaoImpl;

public final class DaoFactory {

    public static final Dao c(DBSession session, String sql) {
        return new DaoImpl(session, sql, false);
    }
    
    public static final Dao c(Connector connector, String sql) {
        DBSession session = DBSessionFactory.getSession(connector);
        return new DaoImpl(session, sql, true);
    }
    
    public static final Dao c(String connector, String sql) {
        DBSession session = DBSessionFactory.getSession(connector);
        return new DaoImpl(session, sql, true);
    }

    public static final Dao c(String sql) {
        DBSession session = DBSessionFactory.getSession();
        return new DaoImpl(session, sql, true);
    }
    
    public static final Dao c(String sql, Class<? extends Entity> retType) {
        DBSession session = DBSessionFactory.getSession();
        return new DaoImpl(session, sql, true).setResultType(retType);
    }
    
    public static final Dao c(String connector, String sql, Class<? extends Entity> retType) {
        DBSession session = DBSessionFactory.getSession(connector);
        return new DaoImpl(session, sql, true).setResultType(retType);
    }
}
